//
//  MassgeDataModel.m
//  YZZX
//
//  Created by Easaa on 15/4/28.
//  Copyright (c) 2015年 Easaa. All rights reserved.
//

#import "CommentDataModel.h"


#import "LFURlRequest.h"
#import "LFDataRequest.h"
#import "CommentQuoteData.h"

@implementation CommentDataModel
{
    HXHttpRequest   *_httpRequest;

}


-(id)initWithDataModel:(NSDictionary *)dicuu
{
    self = [super init];
    if (self)
    {
        
        self.Content                    = [dicuu objectForKey:@"Content"];
        self.Image                      = [dicuu objectForKey:@"Image"];
        self.LastChangedTime            = [dicuu objectForKey:@"LastChangedTime"];
        self.Order                      = [dicuu objectForKey:@"Order"];
        self.ReleaseDate                = [dicuu objectForKey:@"ReleaseDate"];
        self.Source                     = [dicuu objectForKey:@"Source"];
        self.Subtitle                   = [dicuu objectForKey:@"Subtitle"];
        self.Summary                    = [dicuu objectForKey:@"Summary"];
        self.Title_massge               = [dicuu objectForKey:@"Title"];
        self.id_massge                  = [dicuu objectForKey:@"id"];

        
        self.DtatCellModel = [[NSMutableArray alloc]init];

    }
    
    return self;

}





#pragma mark 传入一个object_id请求跟帖数据，返回跟帖数据数组
-(NSArray *)categoryListRequestWithObjectID:(NSString *)object_id

{
  
    //因要传入object_id，借用这个固定字段传入

    __block NSArray *arryData;
    
    NSURLRequest *urlRequest = [LFURlRequest getUrlRequestWithMethod:YZ_COMMENT_LIST
                                                           andParams:@{@"user_id":      [XSZ_UICommon useridChangUaerdfLoginBoolString],
                                                                       @"site_id":      @"1",
                                                                       @"page_no":      [NSNumber numberWithInteger:1],
                                                                       @"page_size":    [NSNumber numberWithInteger:10],
                                                                       @"app":          @"articles",
                                                                       @"model":        @"article",
                                                                       @"object_id":    object_id
                                                                           }];
    
    [LFDataRequest dataRequestWith:urlRequest complete:^(id responseData, NSError *error) {
        if (error)
        {
         
        } else if (responseData)
        {
            if ([responseData isKindOfClass:[NSDictionary class]])
            {
                NSDictionary *dic = responseData;
                if ([[dic objectForKey:@"is_success"] boolValue])
                {
                    NSString *strData = [dic objectForKey:@"data"];
                    if (!StringIsEmpty(strData))
                    {
//                        dispatch_main_async_safe(^{
                        
                            arryData = [JsonUtil jsonToArray:strData];
                            
                            
//                        });
                        
                    }
                } else
                {
                    
                    
                }
            }
        }
    }];
    
    return arryData;
}

//
//#pragma mark 根据传过来的数组返回一个序列化数组
//-(NSArray *)convertarrytModel:(NSArray *)arry
//{
//    NSMutableArray *arrydata =[[NSMutableArray alloc]init];
//    for (NSDictionary *diccomm in arry)
//    {
//       CommentQuoteData *dicmdoel =  [self convertToYZZXCommentModel:diccomm];
//        [arrydata addObject:dicmdoel];
//    }
//
//    return arrydata;
//}
//
//
//#pragma mark c里面处理了具体的跟帖字典
//-(NSDictionary *)convertToYZZXCommentModel:(NSDictionary *)dicdata
//{
//
//    CommentQuoteData  *QuoteData = [[CommentQuoteData alloc]initWithDataComment:dicdata];
//    
//    if (QuoteData.quote!=NULL)
//    {
//      CommentQuoteData *dic = [self convertToYZZXCommentModel:QuoteData.quote];
//        QuoteData.quote = dic;
//    }
//   
//    return QuoteData.quote;
//}


//+ (NSArray *)convertToYZZXCommentModel:(NSArray *)ary
//{
//    NSMutableArray *mArray = [NSMutableArray arrayWithCapacity:ary.count];
//    for (NSDictionary *firstDic in ary)
//    {
//        CategoryDataModel *firstCategoryListModel = [[CategoryDataModel alloc] initWithDataDic:firstDic];
//        
//        id chirldren = [firstDic objectForKey:@"children"];
//        if (chirldren != nil && chirldren != [NSNull null])
//        {
//            NSArray *childrens = [self convertToHXCategoryListModel:chirldren];
//            firstCategoryListModel.children = childrens;
//        }
//        [mArray addObject:firstCategoryListModel];
//    }
//    return mArray;
//}

@end
